with open(r'C:\Users\65506456.NAPP\Desktop\excel.txt','r') as f:
    co=f.read()
with open(r'C:\Users\65506456.NAPP\Desktop\excel.txt','a') as f:
    for i in range(3,32):
        rep1='%d'%i
        rep2='%d'%(i-2)
        co2=co.replace('*',rep1).replace('#',rep2)
        f.write(co2)

